<?php
namespace app\model;
class userData{    /**     * Desc:用户日志的操作类型定义  show控制在前端下拉筛选的时候是否默认显示 1默认显示 0不显示     * User:wyx     * Time: 2022/4/28 9:38 上午     * @param $type     * @return array|array[]     */    public static function dataType($type){        $type_array = [            1  => ['name'=>'浏览','show'=>1],            1001  => ['name'=>'浏览按时间','show'=>1],            2  => ['name'=>'分享好友或群','show'=>1],            3  => ['name'=>'分享朋友圈','show'=>1],            4  => ['name'=>'生成海报','show'=>1],            5  => ['name'=>'点击按扭','show'=>1],            6  => ['name'=>'点击提交','show'=>1],            7  => ['name'=>'支付成功','show'=>1],            8  => ['name'=>'线下绑定','show'=>0],            9  => ['name'=>'退款','show'=>0],            10  => ['name'=>'加入附近团','show'=>0],            11  => ['name'=>'查看定单页','show'=>0],            12  => ['name'=>'查看凭证页','show'=>0],            13  => ['name'=>'查看红包页','show'=>0],            14  => ['name'=>'手工提现','show'=>0],            15  => ['name'=>'扫码核销','show'=>0], //客户扫员工码核销            16  => ['name'=>'员工核销','show'=>0], //员工扫客户码核销            17  => ['name'=>'好友助力','show'=>0],            //九宫格抽奖            18  => ['name'=>'获取机会','show'=>0],            19  => ['name'=>'抽中奖项','show'=>0],            //用户翻牌            20  => ['name'=>'参与翻牌抽奖','show'=>0],            21  => ['name'=>'翻牌中奖','show'=>0],            35  => ['name'=>'获取翻牌机会','show'=>0],            //砍价            22  => ['name'=>'发起砍价','show'=>0],            23  => ['name'=>'帮砍','show'=>0],            24  => ['name'=>'砍价成功','show'=>0],            25  => ['name'=>'帮砍有礼','show'=>0],            //红包雨            26  => ['name'=>'红包雨抽奖','show'=>0],            27  => ['name'=>'红包雨助力','show'=>0],            28  => ['name'=>'查看我的红包','show'=>0],            32  => ['name'=>'红包雨中奖','show'=>0],            33  => ['name'=>'获取红包雨机会','show'=>0],            34  => ['name'=>'查看排行榜','show'=>0],            //盲盒            29 => ['name'=>'拆盲盒','show'=>0],            30 => ['name'=>'选择礼品','show'=>0],            31 => ['name'=>'帮拆盲盒','show'=>0],            //获取手机号            36 => ['name'=>'获取手机号','show'=>0],            37 => ['name'=>'员工注册保存','show'=>0],            38 => ['name'=>'授权头像昵称','show'=>0],            39 => ['name'=>'系统备注','show'=>0],        ];        if($type==-1){            return $type_array;        }        if(isset($type_array[$type])){            return $type_array[$type];        }else{            return ['name' => '未知','show' => 0];        }    }    /**     * Desc:链接类型  color 返回定义的背景色     * User:wyx     * Time: 2022/4/28 9:38 上午     * @param $type     * @return string[]     */    public static function linkType($type){        $type = intval($type);        $array = [            0  => ['name' => '页面跳转','color' => '#FFD700'] , //褐色            1  => ['name' => '好友或群','color' => '#4be6ff'] ,//黄色            2  => ['name' => '朋友圈','color'=>'#96f797'] ,   //绿色            3  => ['name' => '海报','color'=>'#ffbfdb'],     //粉色            8  => ['name' => '刷新页面','color'=>'#fadab8'],   //橙色            9  => ['name' => '管理后台','color'=>'#fadab8'],   //橙色            10  => ['name' => '原始二维码','color'=>'#fadab8'],   //橙色            11  => ['name' => '页面跳转','color' => '#FFD700'] , //褐色            1000  => ['name' => '其他','detail'=>'其他', 'color'=>'#ffb6c1'],            1001  => ['name' => '小程序主入口','detail'=>'发现栏小程序主入口，「最近使用」列表（基础库2.2.4版本起包含「我的小程序」列表）', 'color'=>'#ffc0cb'],            1005  => ['name' => '微信搜索','detail'=>'微信首页顶部搜索框的搜索结果页', 'color'=>'#dc143c'],            1006  => ['name' => '微信搜索','detail'=>'发现栏小程序主入口搜索框的搜索结果页', 'color'=>'#fff0f5'],            1007  => ['name' => '好友点对点','detail'=>'单人聊天会话中的小程序消息卡片', 'color'=>'#4be6ff'],            1008  => ['name' => '微信群','detail'=>'群聊会话中的小程序消息卡片', 'color'=>'#ff69b4'],            1010  => ['name' => '收藏夹','detail'=>'收藏夹', 'color'=>'#ff1493'],            1011  => ['name' => '海报','detail'=>'扫描二维码', 'color'=>'#ffbfdb'],            1012  => ['name' => '海报','detail'=>'长按图片识别二维码', 'color'=>'#ffbfdb'],            1013  => ['name' => '海报','detail'=>'扫描手机相册中选取的二维码', 'color'=>'#ffbfdb'],            1014  => ['name' => '订阅消息','detail'=>'小程序订阅消息（与1107相同）', 'color'=>'#dda0dd'],            1017  => ['name' => '体验入口','detail'=>'前往小程序体验版的入口页', 'color'=>'#ee82ee'],            1019  => ['name' => '微信钱包','detail'=>'微信钱包（微信客户端7.0.0版本改为支付入口）', 'color'=>'#ff00ff'],            1020  => ['name' => '其他','detail'=>'公众号 profile 页相关小程序列表（已废弃）', 'color'=>'#ff00ff'],            1022  => ['name' => '最近使用','detail'=>'聊天顶部置顶小程序入口（微信客户端6.6.1版本起废弃）', 'color'=>'#8b008b'],            1023  => ['name' => '桌面小程序','detail'=>'安卓系统桌面图标', 'color'=>'#800080'],            1024  => ['name' => '其他','detail'=>'小程序 profile 页', 'color'=>'#ba55d3'],            1025  => ['name' => '海报','detail'=>'扫描一维码', 'color'=>'#ffbfdb'],            1026  => ['name' => '附近的小程序','detail'=>'发现栏小程序主入口，「附近的小程序」列表', 'color'=>'#9932cc'],            1027  => ['name' => '使用过的小程序','detail'=>'微信首页顶部搜索框搜索结果页「使用过的小程序」列表', 'color'=>'#4b0082'],            1028  => ['name' => '我的卡包','detail'=>'我的卡包', 'color'=>'#8a2be2'],            1029  => ['name' => '卡券详情页','detail'=>'小程序中的卡券详情页', 'color'=>'#9370db'],            1030  => ['name' => '自动化测试','detail'=>'自动化测试下打开小程序', 'color'=>'#7b68ee'],            1031  => ['name' => '海报','detail'=>'长按图片识别一维码', 'color'=>'#ffbfdb'],            1032  => ['name' => '海报','detail'=>'扫描手机相册中选取的一维码', 'color'=>'#ffbfdb'],            1034  => ['name' => '微信支付完成页','detail'=>'微信支付完成页', 'color'=>'#e6e6fa'],            1035  => ['name' => '公众号菜单','detail'=>'公众号自定义菜单', 'color'=>'#f8f8ff'],            1036  => ['name' => 'App','detail'=>'App 分享消息卡片', 'color'=>'#0000ff'],            1037  => ['name' => '其它小程序','detail'=>'小程序打开小程序', 'color'=>'#0000cd'],            1038  => ['name' => '其它小程序','detail'=>'从另一个小程序返回', 'color'=>'#191970'],            1039  => ['name' => '其他','detail'=>'摇电视', 'color'=>'#00008b'],            1042  => ['name' => '微信搜索','detail'=>'添加好友搜索框的搜索结果页', 'color'=>'#000080'],            1043  => ['name' => '公众号模版','detail'=>'公众号模版消息', 'color'=>'#4169e1'],            1044  => ['name' => '其它','detail'=>'带 shareTicket 的小程序消息卡片 详情', 'color'=>'#6495ed'],            1045  => ['name' => '朋友圈广告','detail'=>'朋友圈广告', 'color'=>'#b0c4de'],            1046  => ['name' => '朋友圈广告','detail'=>'朋友圈广告详情页', 'color'=>'#778899'],            1047  => ['name' => '海报','detail'=>'扫描小程序码', 'color'=>'#ffbfdb'],            1048  => ['name' => '海报','detail'=>'长按图片识别小程序码', 'color'=>'#ffbfdb'],            1049  => ['name' => '海报','detail'=>'扫描手机相册中选取的小程序码', 'color'=>'#ffbfdb'],            1052  => ['name' => '卡券','detail'=>'卡券的适用门店列表', 'color'=>'#4682b4'],            1053  => ['name' => '微信搜索','detail'=>'搜一搜的结果页', 'color'=>'#87cefa'],            1054  => ['name' => '微信搜索','detail'=>'顶部搜索框小程序快捷入口（微信客户端版本6.7.4起废弃）', 'color'=>'#87ceeb'],            1056  => ['name' => '其它','detail'=>'聊天顶部音乐播放器右上角菜单', 'color'=>'#00bfff'],            1057  => ['name' => '钱包','detail'=>'钱包中的银行卡详情页', 'color'=>'#add8e6'],            1058  => ['name' => '公众号文章','detail'=>'公众号文章', 'color'=>'#b0e0e6'],            1059  => ['name' => '体验版小程序','detail'=>'体验版小程序绑定邀请页', 'color'=>'#5f9ea0'],            1060  => ['name' => '微信支付完成','detail'=>'微信支付完成页（与1034相同）', 'color'=>'#f0ffff'],            1064  => ['name' => '其它','detail'=>'微信首页连Wi-Fi状态栏', 'color'=>'#e0ffff'],            1065  => ['name' => '其它','detail'=>'URL scheme 详情', 'color'=>'#afeeee'],            1067  => ['name' => '公众号文章','detail'=>'公众号文章广告', 'color'=>'#00ffff'],            1068  => ['name' => '附近小程序','detail'=>'附近小程序列表广告（已废弃）', 'color'=>'#00ffff'],            1069  => ['name' => 'App','detail'=>'移动应用通过openSDK进入微信，打开小程序', 'color'=>'#00ced1'],            1071  => ['name' => '钱包','detail'=>'钱包中的银行卡列表页', 'color'=>'#2f4f4f'],            1072  => ['name' => '二维码收款页','detail'=>'二维码收款页面', 'color'=>'#008b8b'],            1073  => ['name' => '客服消息','detail'=>'客服消息列表下发的小程序消息卡片', 'color'=>'#008080'],            1074  => ['name' => '客服消息','detail'=>'公众号会话下发的小程序消息卡片', 'color'=>'#48d1cc'],            1077  => ['name' => '其它','detail'=>'摇周边', 'color'=>'#20b2aa'],            1078  => ['name' => '其它','detail'=>'微信连Wi-Fi成功提示页', 'color'=>'#40e0d0'],            1079  => ['name' => '其它','detail'=>'微信游戏中心', 'color'=>'#7fffd4'],            1081  => ['name' => '客服消息','detail'=>'客服消息下发的文字链', 'color'=>'#66cdaa'],            1082  => ['name' => '客服消息','detail'=>'公众号会话下发的文字链', 'color'=>'#00fa9a'],            1084  => ['name' => '朋友圈广告','detail'=>'朋友圈广告原生页', 'color'=>'#f5fffa'],            1088  => ['name' => '会话','detail'=>'会话中查看系统消息，打开小程序', 'color'=>'#00ff7f'],            1089  => ['name' => '最近使用','detail'=>'微信聊天主界面下拉，「最近使用」栏（基础库2.2.4版本起包含「我的小程序」栏）', 'color'=>'#3cb371'],            1090  => ['name' => '最近使用','detail'=>'长按小程序右上角菜单唤出最近使用历史', 'color'=>'#2e8b57'],            1091  => ['name' => '公众号文章','detail'=>'公众号文章商品卡片', 'color'=>'#f0fff0'],            1092  => ['name' => '城市服务','detail'=>'城市服务入口', 'color'=>'#90ee90'],            1095  => ['name' => '小程序广告','detail'=>'小程序广告组件', 'color'=>'#98fb98'],            1096  => ['name' => '聊天记录','detail'=>'聊天记录，打开小程序', 'color'=>'#8fbc8f'],            1097  => ['name' => '微信支付','detail'=>'微信支付签约原生页，打开小程序', 'color'=>'#32cd32'],            1099  => ['name' => '页面跳转','detail'=>'页面内嵌插件', 'color'=>'#00ff00'],            1100  => ['name' => '红包封面','detail'=>'红包封面详情页打开小程序', 'color'=>'#228b22'],            1101  => ['name' => '其它','detail'=>'远程调试热更新（开发者工具中，预览 -> 自动预览 -> 编译并预览）', 'color'=>'#008000'],            1102  => ['name' => '其它','detail'=>'公众号 profile 页服务预览', 'color'=>'#006400'],            1103  => ['name' => '我的小程序','detail'=>'发现栏小程序主入口，「我的小程序」列表（基础库2.2.4版本起废弃）', 'color'=>'#7fff00'],            1104  => ['name' => '我的小程序','detail'=>'微信聊天主界面下拉，「我的小程序」栏（基础库2.2.4版本起废弃）', 'color'=>'#7cfc00'],            1106  => ['name' => '微信搜一搜','detail'=>'聊天主界面下拉，从顶部搜索结果页，打开小程序', 'color'=>'#adff2f'],            1107  => ['name' => '订阅消息','detail'=>'订阅消息，打开小程序', 'color'=>'#556b2f'],            1113  => ['name' => '最近使用','detail'=>'安卓手机负一屏，打开小程序（三星）', 'color'=>'#9acd32'],            1114  => ['name' => '最近使用','detail'=>'安卓手机侧边栏，打开小程序（三星）', 'color'=>'#6b8e23'],            1119  => ['name' => '企业微信','detail'=>'【企业微信】工作台内打开小程序', 'color'=>'#f5f5dc'],            1120  => ['name' => '企业微信','detail'=>'【企业微信】个人资料页内打开小程序', 'color'=>'#fafad2'],            1121  => ['name' => '企业微信','detail'=>'【企业微信】聊天加号附件框内打开小程序', 'color'=>'#fffff0'],            1124  => ['name' => '一物一码','detail'=>'扫“一物一码”打开小程序', 'color'=>'#ffffe0'],            1125  => ['name' => '一物一码','detail'=>'长按图片识别“一物一码”', 'color'=>'#ffff00'],            1126  => ['name' => '一物一码','detail'=>'扫描手机相册中选取的“一物一码”', 'color'=>'#808000'],            1129  => ['name' => '微信爬虫访问','detail'=>'微信爬虫访问 详情', 'color'=>'#bdb76b'],            1131  => ['name' => '浮窗','detail'=>'浮窗（8.0版本起仅包含被动浮窗）', 'color'=>'#fffacd'],            1133  => ['name' => '其它','detail'=>'硬件设备打开小程序 详情', 'color'=>'#eee8aa'],            1135  => ['name' => '其它','detail'=>'小程序profile页相关小程序列表，打开小程序', 'color'=>'#f0e68c'],            1144  => ['name' => '公众号文章','detail'=>'公众号文章 - 视频贴片', 'color'=>'#ffd700'],            1145  => ['name' => '发现小程序','detail'=>'发现栏 - 发现小程序', 'color'=>'#fff8dc'],            1146  => ['name' => '其它','detail'=>'地理位置信息打开出行类小程序', 'color'=>'#daa520'],            1148  => ['name' => '其它','detail'=>'卡包-交通卡，打开小程序', 'color'=>'#b8860b'],            1150  => ['name' => '其它','detail'=>'扫一扫商品条码结果页打开小程序', 'color'=>'#fffaf0'],            1151  => ['name' => '发现小程序','detail'=>'发现栏 - 我的订单', 'color'=>'#fdf5e6'],            1152  => ['name' => '订阅号视频','detail'=>'订阅号视频打开小程序', 'color'=>'#f5deb3'],            1153  => ['name' => '页面跳转','detail'=>'“识物”结果页打开小程序', 'color'=>'#ffe4b5'],            1154  => ['name' => '朋友圈单页','detail'=>'朋友圈内打开“单页模式”', 'color'=>'#96f797'],            1155  => ['name' => '朋友圈','detail'=>'“单页模式”打开小程序', 'color'=>'#96f797'],            1157  => ['name' => '客服消息','detail'=>'服务号会话页打开小程序', 'color'=>'#ffebcd'],            1158  => ['name' => '群工具','detail'=>'群工具打开小程序', 'color'=>'#ffdead'],            1160  => ['name' => '群待办','detail'=>'群待办', 'color'=>'#faebd7'],            1167  => ['name' => 'H5进入小程序','detail'=>'H5 通过开放标签打开小程序 详情', 'color'=>'#d2b48c'],            1168  => ['name' => 'APP进入小程序','detail'=>'移动应用直接运行小程序', 'color'=>'#deb887'],            1169  => ['name' => '发现小程序','detail'=>'发现栏小程序主入口，各个生活服务入口（例如快递服务、出行服务等）', 'color'=>'#ffe4c4'],            1171  => ['name' => '其它','detail'=>'微信运动记录（仅安卓）', 'color'=>'#ff8c00'],            1173  => ['name' => '其它','detail'=>'聊天素材用小程序打开 详情', 'color'=>'#faf0e6'],            1175  => ['name' => '视频号','detail'=>'视频号主页商店入口', 'color'=>'#cd853f'],            1176  => ['name' => '视频号直播间','detail'=>'视频号直播间主播打开小程序', 'color'=>'#ffdab9'],            1177  => ['name' => '视频号直播商品','detail'=>'视频号直播商品', 'color'=>'#f4a460'],            1178  => ['name' => '在电脑打开手机上打开的小程序','detail'=>'在电脑打开手机上打开的小程序', 'color'=>'#d2691e'],            1179  => ['name' => '#话题页打开','detail'=>'#话题页打开小程序', 'color'=>'#8b4513'],            1181  => ['name' => '网站应用','detail'=>'网站应用打开PC小程序', 'color'=>'#fff5ee'],            1183  => ['name' => 'PC发现小程序','detail'=>'PC微信 - 小程序面板 - 发现小程序 - 搜索', 'color'=>'#a0522d'],            1185  => ['name' => '群公告','detail'=>'群公告', 'color'=>'#ffa07a'],            1186  => ['name' => '收藏 - 笔记','detail'=>'收藏 - 笔记', 'color'=>'#ff7f50'],            1187  => ['name' => '浮窗','detail'=>'浮窗（8.0版本起）', 'color'=>'#ff4500'],            1189  => ['name' => '其它','detail'=>'表情雨广告', 'color'=>'#e9967a'],            1191  => ['name' => '视频号','detail'=>'视频号活动', 'color'=>'#ff6347'],            1192  => ['name' => '企业微信','detail'=>'企业微信联系人profile页', 'color'=>'#ffe4e1'],            1194  => ['name' => '其它','detail'=>'URL Link 详情', 'color'=>'#fa8072'],            1195  => ['name' => '视频号','detail'=>'视频号主页商品tab', 'color'=>'#fffafa'],            1197  => ['name' => '视频号','detail'=>'视频号主播从直播间返回小游戏', 'color'=>'#f08080'],            1198  => ['name' => '视频号','detail'=>'视频号开播界面打开小游戏', 'color'=>'#bc8f8f'],            1202  => ['name' => '企微客服号','detail'=>'企微客服号会话打开小程序卡片', 'color'=>'#cd5c5c'],            1203  => ['name' => '微信小程序压测工具','detail'=>'微信小程序压测工具的请求', 'color'=>'#ff0000'],            1206  => ['name' => '视频号','detail'=>'视频号小游戏直播间打开小游戏', 'color'=>'#a52a2a'],            1207  => ['name' => '企微客服号','detail'=>'企微客服号会话打开小程序文字链', 'color'=>'#b22222'],            1208  => ['name' => '聊天打开商品卡片','detail'=>'聊天打开商品卡片', 'color'=>'#8b0000'],            1212  => ['name' => '其它','detail'=>'青少年模式申请页打开小程序', 'color'=>'#800000'],            1215  => ['name' => '其它','detail'=>'广告预约打开小程序', 'color'=>'#ffe4b5 '],            1216  => ['name' => '视频号','detail'=>'视频号订单中心打开小程序', 'color'=>'#f5deb3']        ];        if (empty($array[$type])){            return ['name' => '未知'.$type,'color' => '#cdefff'];        }else{            return $array[$type];        }    }    /**     * Desc:添加用户日志记录     * User:wyx     * Time: 2022/4/28 9:37 上午     * @param $themeid     * @param $uid     * @param $type @dataType() 方法里定义的日志记录类型     * @param string $remark    备注 如抽奖三次等     * @param int $workerid     * @param int $fromuid     * @param int $link_type  @linkType() 方法里定义的链接类型     * @param int $path_id     关系路径id     * @param false $isworker   H5使用     */    public static function addLog($themeid,$uid,$type,$remark='',$workerid=0,$fromuid=0,$link_type=0,$path_id=0,$isworker = false)    {        global $_G,$_P;        if (empty($uid)){            return ;        }        $_P['chushi'] = array(            'themeid'=>$themeid,            'uid'=>$uid,            'type'=>$type,            'remark'=>$remark,            'workerid'=>$workerid,            'fromuid'=>$fromuid,            'link_type'=>$link_type,            'path_id'=>$path_id,            'isworker'=>$isworker,        );        //添加流量记录        if($type==1){            $theme = Theme::getThemeById($themeid);            if($theme['endtime']>time()&& DOMAIN0!="33.yixuan.net") {                $softwore = substr(MODULE_NAME, 2);                $server = strlen($softwore) == 5 ? substr($softwore, 0, 2) : substr($softwore, 0, 3);                $time = strtotime(date('Y-m-d H:i', time()));                $scan = 1;                if (!empty(software)){                    $flow_sql = " INSERT INTO " . tablename('000_flow') . " (server,software,time,scan) VALUES ({$server},{$softwore},{$time},{$scan}) ON DUPLICATE KEY UPDATE scan = scan+{$scan}";                    $flow_res = db_query($flow_sql);                }            }        }        if ($uid != $workerid){            if ($uid==$_G['member']['uid']){                $nickname = $_G['member']['nickname'];            }            if (empty($nickname)){                $fans = Fans::getById($uid,$themeid);                $nickname = $fans['nickname'];            }            if (!empty($nickname)) {                if (strpos($nickname, "易宣") !== false) {                    return;                }            }        }        $path_id = intval($path_id);        $workerid = intval($workerid);        $link_type = intval($link_type);        $fromuid = intval($fromuid);        $type = intval($type);        if ($type ==1 && ($link_type=='1047' || $link_type=='1048' || $link_type=='1049' || $link_type=='0') && empty($fromuid)){            $link_type = 10;        }        //同一时间事件        $user_all_sql = "select * from ".tablename(t_userdata_record)." where `uid` = '{$uid}' and `type` = {$type} order by id desc limit 1";        $user_all_data = db_find($user_all_sql);        if (!empty($user_all_data)){            $stay_time = time()-strtotime($user_all_data['create_time']);            if ($type==1){                if ($stay_time<2 && $fromuid == $uid){                    return ;                }                if (empty($user_all_data['standing_time']) && $stay_time<600){                    db_update(t_userdata_record,array('standing_time'=>$stay_time),array('id'=>$user_all_data['id']));//                    $link_type=8;                    $remark .='刷新页面';                }            }        }        $userall_where = " uid=".$uid." and themeid=".$themeid;        $user_all_sql = "select  id,uid,from_uid,from_uids,workerid,workerids,is_pay,path_id,ifnull(typesnum->>'$.\"$type\"',0)  AS type_num from ".tablename(t_userdata_all)." where ".$userall_where;        $user_all_data = db_find($user_all_sql);        $is_add = 1;        $now_type_num = 0;        if($user_all_data){            //存在数据用户总数据            $is_add = 0;            $new_type_num =intval($user_all_data['type_num'])+1;            $now_type_num = $user_all_data['type_num'];            $update_field = 'update_time='."'".date('Y-m-d H:i:s',time())."'";            if ($type == 9){                $update_field .= ',is_pay=false,pay_time=NULL';            }            //只有浏览页面时才更新关系数据            if ( $type == 1 || $type == 7){                if ($type == 7){                    $update_field .= ',is_pay=true,pay_time='."'".date('Y-m-d H:i:s',time())."'";                }                if($user_all_data['is_pay']==0 ){                    if ($fromuid != $uid){                        $update_field .= ',from_uid='.$fromuid.',path_id='.$path_id;                    }                    if ($isworker){                        $update_field.= ',workerid='.$uid;                    }else{                        $update_field.= ',workerid='.$workerid;                    }                }                if ($fromuid != $uid) {                    if ($user_all_data['from_uids']) {                        $from_uids_array = explode(',', $user_all_data['from_uids']);                        if (!in_array($fromuid, $from_uids_array)) {                            $from_uids_array[] = $fromuid;                            $from_uids_str = implode(',', $from_uids_array);                            $update_field .= ",from_uids='" . $from_uids_str . "'";                        }                    } else {                        $update_field .= ',from_uids=' . $fromuid;                    }                }                if ($isworker) {                    $update_field .= ',workerids=' . $workerid;                }else{                    if ($user_all_data['workerids']) {                        $workerids_array = explode(',', $user_all_data['workerids']);                        if (!in_array($workerid, $workerids_array)) {                            $workerids_array[] = $workerid;                            $workerids_str = implode(',', $workerids_array);                            $update_field .= ",workerids='" . $workerids_str . "'";                        }                    } else {                        $update_field .= ',workerids=' . $workerid;                    }                }            }//            if($type==3){   //支付//                $update_field.= ',is_pay=1';//            }            $update_field.= ",typesnum=JSON_SET(typesnum,'$.\"$type\"',$new_type_num)";            $update_sql =  "UPDATE ".tablename(t_userdata_all)." SET ".$update_field .'where id ='.$user_all_data['id'];        }else{            $all_data = [                'themeid' => $themeid,                'uid' => $uid,                'from_uid' => $fromuid,                'workerid' => $workerid,                'from_uids' => $fromuid,                'workerids' => $workerid,                'path_id' => $path_id,                'typesnum' =>   json_encode([$type=>1]),                'create_time' => date('Y-m-d H:i:s',time())            ];        }        if($workerid==0&&$link_type!=1){            $worker_data = db_find('SELECT workerid FROM ' . tablename ( t_userdata_record ) . " WHERE themeid ={$themeid} AND uid = {$uid} AND type = 1 ORDER BY id DESC");;            $workerid = $worker_data['workerid']?$worker_data['workerid']:0;        }        $new_type_num =$now_type_num+1;        $post = $_P;        unset($post['pdata']);        $record_data = [            'uid' => $uid,            'themeid' => $themeid,            'from_uid' => $fromuid,            'workerid' => $workerid,            'type' => $type,            'link_type' => $link_type,            'path_id' => $path_id,            'type_num' => $new_type_num,            'remark' => $remark,            'url' => $_G['url_scheme'].$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],            'post' => json_encode($post),            'create_time' => date('Y-m-d H:i:s',time())        ];        $res = $insertid = db_insert(t_userdata_record,$record_data);        if($is_add){   // 添加            $res = $insertid = db_insert(t_userdata_all,$all_data);            //创建我的路径        }else{//修改            $res = db_query($update_sql);        }        return $res;    }    //返回默认重点关注    public static function getDefaultType()    {        $userdata_type =array();        $userdata_type[]= array(            'type' => 1,            'greater' => 5,        );        $userdata_type[]= array(            'type' => 2,            'greater' => 2,        );        $userdata_type[]= array(            'type' => 3,            'greater' => 2,        );        $userdata_type[]= array(            'type' => 5,            'greater' => 2,        );        $userdata_type[]= array(            'type' => 6,            'greater' => 1,        );        return $userdata_type;    }    /**     * Desc:返回我的路径id     * User:wyx     * Time: 2022/4/28 9:36 上午     * @param $themeid     * @param $workerid     * @param $uid     * @param $pid     * @return int|void     */    public static function MyPath($themeid,$workerid,$uid,$pid,$recordid=0){        $is_new = false;        $pid = intval($pid);        $uid = intval($uid);        $workerid = intval($workerid);        $recordid = intval($recordid);        if (empty($uid)){            return 0;        }        if ($recordid>0 && $workerid==$uid){            $record = Record::getById($recordid);            if (!($record['status']>0 && $record['uid']==$workerid)){                $is_new =true;            }        }        if(!$is_new){            if ($pid>0){                $relation = db_get(t_userdata_relation, array('id'=>$pid));                if (!empty($relation)){                    if ($relation['from_uid']==$uid && $relation['workerid']==$workerid && $relation['recordid']==$recordid){                        return $pid;                    }                }            }            $my_path = db_get(t_userdata_relation, array('from_uid' => $uid,'workerid' => $workerid,'recordid' => $recordid,'pid'=>$pid));            if (empty($my_path)){                $is_new = true;            }else{                return $my_path['id'];            }        }        if($is_new){            if($pid==0){                $path = $uid;            }else{                $path = !empty($relation['path'])?$relation['path'].','.$uid:$uid;            }            if ($uid != $workerid){                $worker_list = Userdata::getWorkerUidAndName($themeid,$uid);                if (!empty($worker_list)){                    $workerid = $uid;                }            }            $relation_data = [                'themeid' => $themeid,                'from_uid' => $uid,                'workerid' => $workerid,                'path' => $path,                'pid' => $pid,                'recordid' => $recordid,                'create_time' => date('Y-m-d H:i:s',time())            ];            $insertid = db_insert(t_userdata_relation,$relation_data);            return $insertid;        }    }    /**     * Desc:     * User:wyx     * Time: 2022/4/28 9:34 上午     * @param $type     * @return int     */    public static function visitType($type){        $array = [1];        if(in_array($type,$array)){            return 1;        }else{            return 0;        }    }    /**     * Desc:追踪类型     * User:wyx     * Time: 2022/4/28 9:59 上午     * @param $type     * @return string     */    public static function signType($type){        $array = [            1  => '已追踪',            2  => '意向用户',            3  => '潜在用户',            4  => '无意向用户',        ];        return $array[$type];    }    /**     * Desc:追踪类型的标签     * User:wyx     * Time: 2022/4/28 10:04 上午     * @param $type     * @return string     */    public static function showSignType($type){        $array = [            1  => '已追踪',            2  => '意向',            3  => '潜在',            4  => '无意向',        ];        return $array[$type];    }    //其他类型    public static function otherType($field){        $type = 0;        switch ($field){            case 'exist_mobile_num':                $type = 901;                $name = '有手机号';                break;//            case 'exist_nickname_and_avavar_num'://                $type = 902;//                $name = '有昵称头像';//                break;            case 'nickname_exist_mobile_num':                $type = 903;                $name = '昵称带手机号';                break;        }        return ['type'=>$type,'name'=> $name];    }    /**     * Desc:获取员工id和名称     * User:wyx     * Time: 2022/4/28 10:05 上午     * @param $themeid     * @param $workerid     * @return mixed     */    public static function getWorkerUidAndName($themeid,$workerid){        $where = "themeid=".$themeid;        if($workerid){            if(strpos($workerid,',')){                $where .= " and uid in(". $workerid.")";            }else{                $where .= ' and uid ='. $workerid;            }        }        $workersql = "SELECT uid,username FROM ".tablename(t_worker) ."  WHERE ".$where;        $workerlist = db_select($workersql);        return $workerlist;    }    /**     * Desc:获取员工信息     * User:wyx     * Time: 2022/4/28 10:07 上午     * @param $themeid     * @param $cachekey     * @return mixed     */    public static function getWorkerInfo($system,$themeid,$page_index=1){        $cachekey ='worker'.MODULE_NAME.$themeid;        $workerlist = cache_load($cachekey);        if (empty($workerlist) || $page_index==1){            if($system['is_multiple_merchants']) {                $shangjia_sql1 = ", left(s.name,8)  as compnay_name";                $shangjia_sql2 = " LEFT JOIN " . tablename(t_shangjia) . " AS s on w.company=s.id ";            }else{                $shangjia_sql1 = ",'' as compnay_name";            }            $workersql = "SELECT w.id,w.uid,w.username,ifnull(w.avatar,'https://css2020.yixuan.net/2020css/yx2020/images/question.png') as avatar,left(t.name,5) as team_name{$shangjia_sql1} FROM ".tablename(t_worker) .' AS w '.                " LEFT JOIN " . tablename(t_team) . " AS t on w.team=t.id " .                $shangjia_sql2.                " WHERE w.themeid=".$themeid;            $workerlist = db_select($workersql,array(),'uid');            cache_write($cachekey,$workerlist);      //缓存        }        return $workerlist;    }    /**     * Desc:获取用户信息和用户总数据     * User:wyx     * Time: 2022/4/28 10:07 上午     * @param $themeid     * @param $uid     * @return array     */    public static function getUserAllData($themeid,$uid){        $user_info_sql = "SELECT  uid,avatar,nickname,username,mobile FROM ".tablename(t_fans) ." WHERE uid = ".$uid ." AND themeid=".$themeid;        $user_info = db_find($user_info_sql);        //        $user_data_sql = "SELECT * FROM ".tablename(t_userdata_all) ." WHERE uid = ".$uid ." AND themeid=".$themeid;        $user_data = db_find($user_data_sql);        $types_data = array();        if($user_data){            //好友下单 我的上下级和我有关联的//            $pay_count1 = db_find("SELECT count(*) as cnt FROM ".tablename(t_userdata_all) ." WHERE uid in (".$user_data['from_uids'].") AND is_pay = 1 AND themeid =".$themeid);//            $pay_count2 = db_find("SELECT count(*) as cnt FROM ".tablename(t_userdata_all) ." WHERE themeid=".$themeid." AND is_pay=1 AND FIND_IN_SET($uid,'from_uids')");            if(!$user_info['avatar']){                $user_info['avatar'] = 'https://css2020.yixuan.net/2020css/yx2020/images/question.png';            }            $types_data = self::typesNum($user_data['typesnum']);            $user_data['sign_name'] = self::showSignType($user_data['sign_type']);            if($user_data['trace_next_time']=='0000-00-00 00:00:00'){                $user_data['trace_next_time'] = '';            }        }        return [            'info'  => $user_info,            'data'  => $user_data,            'types_data' => $types_data        ];    }    /**     * Desc:返回操作类型以及次数     * User:wyx     * Time: 2022/4/28 10:08 上午     * @param $typesnum     * @return array     */    public static function typesNum($typesnum){        $types_data = array();        $types_data[1] = [ 'type' => 1,'num'=>0,'name' =>self::dataType(1)['name']];        $types_data[2] = [ 'type' => 2,'num'=>0,'name' =>self::dataType(2)['name']];        $types_data[3] = [ 'type' => 3,'num'=>0,'name' =>self::dataType(3)['name']];        if($typesnum){            $types_array = json_decode($typesnum,true);            foreach ($types_array as  $k=>$v){                if(isset($types_data[$k])){                    $types_data[$k]['num'] = $v;                }else{                    $types_data[$k] = [                        'type' => $k,                        'num' => $v,                        'name' => self::dataType($k)['name'],                    ];                }            }        }        $types_data =  array_values($types_data);        return $types_data;    }    /**     * Desc:员工等级     * User:wyx     * Time: 2022/4/28 10:09 上午     * @param $themeid     * @param $workerid     * @param $level     * @return int|mixed     */    public static function workerLevel($themeid,$workerid,$level){        $worker_id = 0 ;        switch($level){            case 1:      //超级管理员 返回全部                $worker_id = 0;                break;            case 2:     //商家管理员 返回本商家下的员工id[数组]                $company = db_getcolumn(t_worker, array('themeid' => $themeid,'uid' => $workerid), 'company',1);                if($company){                    $workersql = "SELECT group_concat(uid) as uids  FROM ".tablename(t_worker)." WHERE themeid=".$themeid." and company=".$company;                    $worker_id = db_find($workersql)['uids'];                }else{                    $worker=db_find("SELECT * FROM ".tablename(t_worker)." WHERE uid = '{$workerid}'");                    if (!empty($worker['mobile'])) {                        $workersql = "SELECT group_concat(uid) as uids  FROM " . tablename(t_worker) . " WHERE mobile = '{$worker['mobile']}' and username = '{$worker['username']}'";                        $worker_id = db_find($workersql)['uids'];                    }else{                        $worker_id = $workerid;                    }                }                break;            case 3:   //返回本员工//                $worker_id = $workerid;                $worker=db_find("SELECT * FROM ".tablename(t_worker)." WHERE uid = '{$workerid}'");                if (!empty($worker['mobile'])) {                    $workersql = "SELECT group_concat(uid) as uids  FROM " . tablename(t_worker) . " WHERE mobile = '{$worker['mobile']}' and username = '{$worker['username']}'";                    $worker_id = db_find($workersql)['uids'];                }else{                    $worker_id = $workerid;                }                break;        }        return $worker_id;    }    /**     * Desc:员工快捷输入 存在于员工表 后台config有默认     * User:wyx     * Time: 2022/4/28 10:14 上午     * @param $config     * @param $workerid     * @return false|mixed|string[]     */    public static function workerQuickInput($config,$workerid){        $workersql = "SELECT quick_input  FROM ".tablename(t_worker)." WHERE uid=".$workerid;        $quick_input = db_find($workersql);        if($quick_input['quick_input']){            $quick_input = json_decode($quick_input['quick_input']);        }else{            $userdata_reply = $config['userdata_reply'];            $quick_input = explode("\n",trim($userdata_reply));        }        return $quick_input;    }    /**     * Desc:返回所有日志类型的总数据     * User:wyx     * Time: 2022/4/28 10:16 上午     * @param $themeid     * @param $pay_type  是否支付  1 未支付 2 已支付    传0不好判断，查数据库的时候减1     * @return array     */    public static function allTypeNum($themeid,$pay_type){        $where = ' where themeid = '.$themeid;        if($pay_type){            $where  .= ' and is_pay='.($pay_type-1);    //        }        $dataType = self::dataType(-1);        $select_field = 'count(*) as cnt';        foreach ($dataType as $k => $v){            $select_field .= ",sum(ifnull(json_extract(typesnum,'$.\"$k\"'),0)) as \"$k\"";        }        $all_type_sql =  "select ".$select_field."   from ".tablename(t_userdata_all).$where;        $all_types = db_find($all_type_sql);        $types_data[] = [            'type' => 0,            'num' => 0,            'name' => '全部',        ];        $all_num = 0;        foreach ($all_types as  $k=>$v){            if(($k<>'cnt'&&$v>0)||$dataType[$k]['show']==1){                $types_data[] = [                    'type' => $k,                    'num' => $v,                    'name' => $dataType[$k]['name'],                ];                $all_num += $v;            }        }        $types_data[0]['num'] = $all_num;        return $types_data;    }    /**     * Desc:关注列表快捷类型筛选     * User:wyx     * Time: 2022/4/28 10:22 上午     * @param $themeid     * @param $config     * @param $workerids     * @return array     */    public static function focuseQuickSelect($themeid,$config,$workerids){        $userdata_type =  $config['userdata_type'];        $qucik_input = array();        $where = ' where a.themeid ='. $themeid.' and a.is_pay = 0 ';        if($workerids){            if(strpos($workerids,',')){                $workerids = str_replace(",","|",$workerids);                $where.= ' and CONCAT(",", `workerids`, ",") REGEXP ",('.$workerids.'),"';            }else{                $where .= " and find_in_set($workerids,`workerids`) ";            }        }        /*         *exist_mobile_num  存在手机号         *exist_nickname_and_avavar_num 存在昵称和头像的粉丝数量         *nickname_exist_mobile_num   //昵称存在手机号的数量         * */        //存在手机号        //sum((case when  f1.nickname<>'' and f1.avatar <>'' then 1 else 0 end)) as exist_nickname_and_avavar_num,        $fans_sql = " SELECT sum((case when f1.mobile<>'' then 1 else 0 end)) as exist_mobile_num,                             sum((case when f1.nickname REGEXP '[1][3-9][0-9]{9}' then 1 else 0 end)) as nickname_exist_mobile_num 		                 FROM ".tablename(t_userdata_all)." AS a".            " LEFT JOIN " . tablename(t_fans) . " AS f1 on a.uid=f1.uid and a.themeid = f1.themeid".$where;        $all_num  =  db_find($fans_sql);        foreach ($all_num as $k => $a){            $type_array  =   self::otherType($k);            $qucik_input[] = [                'type' => $type_array['type'],                'count' => $a?$a:0,                'num' => 1,                'name' => $type_array['name']            ];        }        if (!empty($userdata_type)){            foreach ($userdata_type as $v){                $type =  $v['type'];                $type_num = $v['greater'];                $where2 = " and typesnum->'$.\"$type\"' >= ".$type_num;                $total_sql = "SELECT count(*) as cnt FROM " . tablename(t_userdata_all)." as a".$where.$where2;                $count =  db_find($total_sql)['cnt'];                $qucik_input[] = [                    'type' => $type,                    'num' => $type_num,                    'count' => $count,                    'name' => Userdata::dataType($v['type'])['name'].$type_num.'次'                ];            }        }        return $qucik_input;    }    /**     * Desc:待追踪的数量 [未到下次预约时间]     * User:wyx     * Time: 2022/4/28 10:24 上午     * @param $themeid     * @return mixed     */    public static function waitTraceNum($themeid){        $now_time = date('Y-m-d H:i:s',time());        $trace_num_sql =  "select count(*) as cnt  from ".tablename(t_userdata_all)." where themeid=".$themeid." and  is_pay=0 and trace_next_time>"."'".$now_time."'";        $wait_trace_num = db_find($trace_num_sql);        return $wait_trace_num['cnt'];    }    /*******************************提交数据***************************/    /**     * Desc:提交追踪记录     * User:wyx     * Time: 2022/4/28 10:25 上午     * @param $themeid     * @param $uid     * @param $workerid     * @param $sign_type  标记类型     * @param $content    标记内容     * @param $next_time  下次追踪时间     * @return array     */    public static function addTrace($themeid,$uid,$workerid,$sign_type,$content,$next_time){        if(!$themeid){            return [ 'error' => 1,'msg' => '活动ID不存在'];        }        if(!$uid){            return ['error' => 1,'msg' => '用户id不存在'];        }        if(!$workerid){            return ['error' => 1,'msg' => '员工id不存在'];        }        if(!$sign_type){            $sign_type = 1;        }        if(!$content){            return ['error' => 1,'msg' => '请输入追踪内容'];        }        if($next_time&&$next_time<date('Y-m-d H:i',time())){            return ['error' => 1,'msg' => '下次回访提醒时间不能小于当前时间'];        }//        if(!$next_time){//            return ['error' => 1,'msg' => '请选择下次'];//        }        $userall_where = " uid=".$uid." and themeid=".$themeid;        $user_all_sql = "select  id,uid,themeid,sign_type,ifnull(collect_data->>'$.\"trace_num\"',0)  AS trace_num from ".tablename(t_userdata_all)." where ".$userall_where;        $user_all_data = db_find($user_all_sql);        $record_data = [            'uid' => $uid,            'themeid' => $themeid,            'workerid' => $workerid,            'sign_type' => $sign_type,            'content' => $content,            'create_time' => date('Y-m-d H:i:s',time())        ];        if($next_time) {            $record_data['next_time'] = $next_time . ':00';        }        $now_trace_num = 0;        if($user_all_data){            $now_trace_num = $user_all_data['trace_num'];        }        $new_trace_num = $now_trace_num+1;        $insertid = db_insert(t_userdata_trace,$record_data);        $type = "trace_num";        $update_field = 'update_time='."'".date('Y-m-d H:i:s',time())."'";        $update_field .= ',sign_type='.$sign_type;        if($next_time){            $update_field .= ',trace_next_time='."'".$next_time."'";        }        $update_field .= ',trace_last_time='."'".date('Y-m-d H:i:s',time())."'";        $update_field .= ",collect_data=JSON_SET(collect_data,'$.\"$type\"',$new_trace_num)";        $update_sql = "UPDATE ".tablename(t_userdata_all)." SET ".$update_field .' where id ='.$user_all_data['id'];        $res = db_query($update_sql);        if($res){            return ['error' => 0,'msg' => '添加成功'];        }else{            return ['error' => 1,'msg' => '添加失败'];        }    }    /**     * Desc:提交快捷输入     * User:wyx     * Time: 2022/4/28 10:25 上午     * @param $themeid     * @param $workerid     * @param $content     * @return array|void     */    public static function submitQuickInput($themeid,$workerid,$content){        if(!$content){            return ['error' => 1,'msg' => '请输入快捷输入内容'];        }        $content = explode("\n",trim($content));        if($content){            $count =  count($content);            $str = '';            foreach ($content as $k => $v){                $end=$k+1<$count?",":"";                if(trim($v)){                    $str.="'".trim($v)."'".$end;                }            }            $update_sql = "UPDATE ".tablename(t_worker)." SET  quick_input=JSON_ARRAY($str) where uid =".$workerid." and themeid=".$themeid;            $res = db_query($update_sql);            if($res!==false){                return ['error' => 0,'msg' => '操作成功','data'=>['content'=>$content]];            }else{                return ['error' => 1,'msg' => '操作失败'];            }        }    }    /*******************************展示列表***************************/// logdata    /**     * Desc:用户日志列表     * User:wyx     * Time: 2022/4/28 10:28 上午     * @param $themeid     * @param $workerid   根据员工等级判断 level=1 workerid=0 全部  level=2 workerid是id字符串  level=3 workerid是员工本身     * @param $select_workerid   搜索员工id     * @param $keyword           搜索关键字     * @return array     */    public static function  logdataList($system,$config,$themeid,$workerid,$select_workerid,$my_workerid,$is_refresh,$keyword,$limit_uid = true,$limit_avatar = true){        global $_G,$_P,$_S,$_C;        $page_index = max(1,intval($_P['page']));        if($page_index>25){            $info = [                'hasNext'=>false,                'curPageData'=>[],                'page'=>$page_index,                'totalPage'=>25,                'totalSize'=>500,            ];            return $info;        }        $worker_list = self::getWorkerInfo($system,$themeid,$page_index);        $condition = ' where r.themeid ='. $themeid.' and f1.`login_status` =1';        if ($limit_uid){            $condition .= ' and r.uid >0';        }        if($select_workerid){    //选择了员工输入            $condition .= ' and r.workerid ='. $select_workerid;        }else{            if($workerid){                if(strpos($workerid,',')){                    $condition .= " and r.workerid in(". $workerid.")";                }else{                    $condition .= ' and r.workerid ='. $workerid;                }            }        }//        $condition .=" and ((f1.nickname not LIKE '%新用户%' and f1.nickname not LIKE '%微信用户%' and f1.avatar != 'https://css2020.yixuan.net/2020css/yx2020/images/question.png' and f1.avatar IS NOT NULL and f1.avatar != '')//                           or (f1.mobile is not null and  f1.mobile !='' and  ( f1.nickname LIKE '%新用户%' or f1.nickname LIKE '%微信用户%' or f1.avatar = 'https://css2020.yixuan.net/2020css/yx2020/images/question.png' or  f1.avatar IS NULL))//                          )";//        or f1.mobile is not null and  f1.mobile !='' and  f1.nickname LIKE '%新用户%'//        or f1.mobile is not null and  f1.mobile !='' and  f1.nickname LIKE '%微信用户%'//        or f1.mobile is not null and  f1.mobile !='' and  f1.avatar = 'https://css2020.yixuan.net/2020css/yx2020/images/question.png'//        or f1.mobile is not null and  f1.mobile !='' and  f1.avatar IS NULL        $cache_key = MODULE_NAME.'_userdatalogs_'.$themeid.'_'.$my_workerid;        $count_cache_key = $cache_key.'_maxid';        $data_cache_key = $cache_key.'_data';        $limit_nickname = ['不在活动地区','易宣'];        $page_cache = 0;        if($page_index==1){            $fans_condition = '';            if (!empty($limit_nickname)){                foreach ($limit_nickname as $v){                    $fans_condition .= " and nickname not LIKE '%".$v."%' ";                }            }            $fans_condition .="  and ( nickname not LIKE '%新用户%' and nickname not LIKE '%微信用户%' and avatar != 'https://css2020.yixuan.net/2020css/yx2020/images/question.png' and avatar IS NOT NULL and avatar != ''                                       or ( mobile is not null and  mobile !='' and ( nickname LIKE '%新用户%' or  nickname LIKE '%微信用户%' or avatar = 'https://css2020.yixuan.net/2020css/yx2020/images/question.png' or avatar IS NULL))                                  )";            // $fans_condition .=   " IF(mobile is null, and nickname not LIKE '%新用户%' and nickname not LIKE '%微信用户%' and avatar != 'https://css2020.yixuan.net/2020css/yx2020/images/question.png' ,true);)";            // $fans_condition .= " and avatar != 'https://css2020.yixuan.net/2020css/yx2020/images/question.png'";            $fans_update_sql = " update ".tablename(t_fans) ." SET `login_status` =1 where `login_status` !=1  and uid > 0  {$fans_condition}";            db_query("$fans_update_sql");            if($select_workerid>0||!empty($keyword)){                if(cache_load($count_cache_key)){                    cache_delete($count_cache_key);                }                if(cache_load($data_cache_key)){                    cache_delete($data_cache_key);                }            }else{                if(cache_load($count_cache_key)){                    $maxid_where = ' and id>='.cache_load($count_cache_key);                }else{                    $maxid_where = ' and id>=0';                }                if($workerid){                    if(strpos($workerid,',')){                        $maxid_where .= " and workerid in(". $workerid.")";                    }else{                        $maxid_where .= ' and workerid ='. $workerid;                    }                }                $maxid = db_fetchcolumn("SELECT max(id) FROM ".tablename(t_userdata_record)." where themeid = {$themeid} {$maxid_where}");                if(!cache_load($count_cache_key)){                    $page_cache = 1;                    cache_write($count_cache_key,$maxid,3600);                }else{                    if(cache_load($count_cache_key)!=$maxid){                        cache_write($count_cache_key,$maxid,3600);                        $page_cache = 1;                    }else{                        $page_cache = 2;                    }                }            }        }else{            if(cache_load($count_cache_key)){                $condition.=' and r.id<='.cache_load($count_cache_key);            }        }        if($page_cache==2&&cache_load($data_cache_key)){            $cache_data = cache_load($data_cache_key);            $cache_data['cache'] = 1;//            $cache_data['is_refresh'] = 0;//            if($is_refresh){//                $cache_data['curPageData'] = [];//                $cache_data['is_refresh'] = 1;//            }            return $cache_data;            exit();        }        if($keyword){            $condition .= " AND (f1.nickname LIKE '%".$keyword."%'"." or f1.mobile LIKE '".$keyword."' "." or f1.username LIKE '%".$keyword."%')";        }        $total_sql = "SELECT count(r.id) as cnt FROM " . tablename(t_userdata_record)." as r ".            " LEFT JOIN " . tablename(t_fans) . " AS f1 on r.uid=f1.uid and r.themeid = f1.themeid "            .$condition;        $count = db_find($total_sql)['cnt'];        $page_size = $_P['page_size']?$_P['page_size']:20;        $page_start = ($page_index-1)*$page_size;        $condition .= " ORDER BY r.id desc ";        $condition .= " LIMIT " . $page_start . "," . $page_size;        $sql = "SELECT r.*,              ifnull(f1.avatar,'https://css2020.yixuan.net/2020css/yx2020/images/question.png') as user_avater,              ifnull(f1.nickname,'') as user_nickname,ifnull(f1.username,'') as user_username,              ifnull(f1.mobile,'') as user_mobile,              ifnull(f2.avatar,'https://css2020.yixuan.net/2020css/yx2020/images/question.png') as fromuser_avater,              ifnull(f2.nickname,'') as fromuser_nickname,              ifnull(f2.username,'') as fromuser_username,              ifnull(f2.mobile,'') as fromuser_mobile,              a.is_pay,a.sign_type  FROM " . tablename(t_userdata_record) . " AS  r " .            " LEFT JOIN " . tablename(t_fans) . " AS f1 on r.uid=f1.uid and r.themeid = f1.themeid" .            " LEFT JOIN " . tablename(t_fans) . " AS f2 on r.from_uid=f2.uid and r.themeid = f2.themeid" .            " LEFT JOIN " . tablename(t_userdata_all) . " AS a on r.uid=a.uid and r.themeid = a.themeid".$condition;        $list = db_select($sql);        $weibukuan_user = array();        $yibukuan_user = array();        $is_bukuan = 0;        if ($config['yukuan'] > 0 && TIMESTAMP > $config['yukuantime']) {            $has_uid = array_unique(array_filter(array_column($list,'uid')));            if($has_uid){                if(count($has_uid)==1){                    $record_where = " AND uid = {$has_uid[0]}";                }else{                    $has_uid = implode(',',$has_uid);                    $record_where = " AND uid in ({$has_uid})";                }                $weibukuan_user_sql ="SELECT id,uid,themeid,status,type,addtime FROM ". tablename ( t_record )."  WHERE themeid ='{$themeid}' AND addtime<'{$config['yukuantime']}' AND status > 0  {$record_where}";                $weibukuan_user = db_select($weibukuan_user_sql,array(),'uid');                $bukuan_user_sql = " SELECT id,uid,themeid,status,type,addtime FROM ".tablename(t_record)." WHERE themeid = {$themeid}  AND addtime>='{$config['yukuantime']}' {$record_where} ";                $yibukuan_user = db_select($bukuan_user_sql,array(),'uid');            }            $is_bukuan = 1;        }        $max_page = ceil($count/$page_size);        if ($max_page>$page_index){            $can_next = true;        }        foreach($list as $k => $val){            $worker = array();            if($val['type']==1){                $worker = $worker_list[$val['workerid']];            }            $link_array  = self::linkType($val['link_type']);            $list[$k]['type_name'] = self::dataType($val['type'])['name'];            $list[$k]['link_name'] = $link_array['name'];            $list[$k]['link_color'] = $link_array['color'];            $list[$k]['sign_name'] = self::showSignType($val['sign_type']);            $list[$k]['show_visit'] = self::visitType($val['type']);            $list[$k]['time_span'] = timeConversion($val['create_time']);            $list[$k]['is_work'] = 0;            if(!$val['user_avater']){                $list[$k]['user_avater'] = 'https://css2020.yixuan.net/2020css/yx2020/images/question.png';            }            if(!$val['fromuser_avater']){                $list[$k]['fromuser_avater'] = 'https://css2020.yixuan.net/2020css/yx2020/images/question.png';            }            if($worker){                if($val['workerid']==$val['from_uid']){                    $list[$k]['is_work'] = 1;                }                $list[$k]['worker'] = trim($worker['compnay_name'].' '.$worker['team_name'].' '.$worker['username']);            }else{                $list[$k]['worker'] = '';            }            $pay_class ='payTag';            if($is_bukuan){   //开启了补尾款  修改is_pay状态                if($weibukuan_user[$val['uid']]&&$yibukuan_user[$val['uid']]){         //存在未补款数据和已补款数据                    $pay_txt ='已补款';                }elseif($weibukuan_user[$val['uid']]){        //存在预付款订单                    $pay_txt ='未补款';                    $pay_class = 'unlabeledTag';                }elseif($yibukuan_user[$val['uid']]){         //存在尾款订单                    $pay_txt ='全款';                    $pay_class ='markTag';                }else{                    $pay_txt ='未付';                }            }else{                $pay_txt = $val['is_pay'] == 1?'已付':'未付';            }            $list[$k]['pay_txt'] = $pay_txt;            $list[$k]['pay_class'] = $pay_class;        }        $info = [            'hasNext'=>$can_next,            'curPageData'=>$list,            'page'=>$page_index,            'totalPage'=>$max_page,            'totalSize'=>$count,        ];        if($page_cache==1){            cache_write($data_cache_key,$info,3600);        }        return $info;    }    /**     * Desc:关注列表     * User:wyx     * Time: 2022/4/28 10:29 上午     * @param $themeid     * @param $workerid    根据员工等级判断 level=1 workerid=0 全部  level=2 workerid是id字符串  level=3 workerid是员工本身     * @param $type        类型     * @param $type_num    类型次数 大于等于     * @return array     */    public static function  focuseList($system,$themeid,$workerid,$type,$type_num){        global $_G,$_P,$_S,$_C;        $page_index = max(1,intval($_P['page']));        if($page_index>50){            $info = [                'hasNext'=>false,                'curPageData'=>[],                'page'=>$page_index,                'totalPage'=>50,                'totalSize'=>500,            ];            return $info;        }        $worker_list = self::getWorkerInfo($system,$themeid,$page_index);        $where = ' where a.themeid ='. $themeid.' and a.is_pay = 0 ';        if($workerid){            if(strpos($workerid,',')){                $workerids = str_replace(",","|",$workerid);                $where.= ' AND CONCAT(",", `workerids`, ",") REGEXP ",('.$workerids.'),"';            }else{                $where .= " and find_in_set($workerid,`workerids`)";            }        }        $record_where =  " where  r.themeid=".$themeid;        if($type==0){            $type = 1;        }        if($type_num==0){            $type_num = 1;        }        $order = " ORDER BY type_num DESC,a.uid ASC";        if($type==901){            $where .= " AND f1.mobile<>''";        }elseif($type==903){            $where .= " AND f1.nickname REGEXP '[1][3-9][0-9]{9}'";        }elseif($type>1000){            $type = $type - 1000;            $record_where .= " AND  r.type=".$type;            $where .= " AND a.typesnum->'$.\"$type\"' >= ".$type_num;            $order = " ORDER BY update_time DESC,a.uid ASC";        }else{            $record_where .= " AND  r.type=".$type;            $where .= " AND a.typesnum->'$.\"$type\"' >= ".$type_num;        }        $total_sql = "SELECT count(*) as cnt FROM " . tablename(t_userdata_all).' as a ' .            " LEFT JOIN " . tablename(t_fans) . " AS f1 on a.uid=f1.uid and a.themeid = f1.themeid".$where;        $page_size = $_P['$page_size']?$_P['$page_size']:10;        $page_start = ($page_index-1)*$page_size;        $limit = " LIMIT " . $page_start . "," . $page_size;        $list_sql = "SELECT a.uid,a.is_pay,a.sign_type,a.workerids,json_extract(a.typesnum,'$.\"$type\"') as type_num,                   ifnull(f1.avatar,'https://css2020.yixuan.net/2020css/yx2020/images/question.png') as user_avater,                   ifnull(f1.nickname,'') as user_nickname,ifnull(f1.username,'') as user_username,                   ifnull(f1.mobile,'') as user_mobile  FROM " . tablename(t_userdata_all)." as a ".            " LEFT JOIN " . tablename(t_fans) . " AS f1 on a.uid=f1.uid and a.themeid = f1.themeid".$where.$order.$limit;        $list = db_select($list_sql);        foreach ($list as $k => $v){            $record_where2 = " and r.uid=".$v['uid'];            $record_sql = "SELECT r.id,r.themeid,r.uid,r.from_uid,r.type,r.type_num,r.link_type,r.create_time,                            f2.avatar as fromuser_avater,f2.nickname as fromuser_nickname,                            f2.username as fromuser_username,f2.mobile as fromuser_mobile  FROM " . tablename(t_userdata_record)." as r ".                " LEFT JOIN " . tablename(t_fans) . " AS f2 on r.from_uid=f2.uid and r.themeid = f2.themeid ".                $record_where.$record_where2. " ORDER BY r.id DESC";            $record = db_find($record_sql);            $list[$k]['from_uid'] = $record['from_uid']?$record['from_uid']:0;            $list[$k]['fromuser_avater'] = $record['fromuser_avater']?$record['fromuser_avater']:'https://css2020.yixuan.net/2020css/yx2020/images/question.png';            $list[$k]['fromuser_nickname'] = $record['fromuser_nickname']?$record['fromuser_nickname']:'';            $list[$k]['fromuser_username'] = $record['fromuser_username']?$record['fromuser_username']:'';            $list[$k]['fromuser_mobile'] = $record['fromuser_mobile']?$record['fromuser_mobile']:'';            $list[$k]['type_num'] = $v['type_num']?$v['type_num']:$record['type_num'];            $list[$k]['create_time'] = $record['create_time'];            $link_array= self::linkType($record['link_type']);            $list[$k]['type_name'] = self::dataType($record['type'])['name'];            $list[$k]['link_name'] = $link_array['name'];            $list[$k]['link_color'] = $link_array['color'];            $list[$k]['sign_name'] = self::showSignType($v['sign_type']);            $list[$k]['show_visit'] = self::visitType($record['type']);            $list[$k]['time_span'] = timeConversion($record['create_time']);            $list[$k]['is_work'] = 0;            $worker = array();            if($v['type']==1){                $worker = $worker_list[$record['workerid']];            }            if($worker){                if($record['workerid']==$record['from_uid']){                    $list[$k]['is_work'] = 1;                }                $list[$k]['worker'] = trim($worker['compnay_name'].' '.$worker['team_name'].' '.$worker['username']);            }else{                $list[$k]['worker'] = '';            }        }        $count = db_find($total_sql)['cnt'];        $max_page = ceil($count/$page_size);        if ($max_page>$page_index){            $can_next = true;        }        $info = [            'hasNext'=>$can_next,            'curPageData'=>$list,            'page'=>$page_index,            'totalPage'=>$max_page,            'totalSize'=>$count,        ];        return $info;    }    /**     * Desc:追踪列表     * User:wyx     * Time: 2022/4/28 10:30 上午     * @param $themeid     * @param $select_workerid     * @param $worker_id  根据员工等级判断 level=1 workerid=0 全部  level=2 workerid是id字符串  level=3 workerid是员工本身     * @param $wait_trace     * @param $keyword     * @return array     */    public static function  traceList($system,$themeid,$select_workerid,$worker_id,$trace_type,$keyword){        global $_G,$_P,$_S,$_C;        $page_index = max(1,intval($_P['page']));        $worker_list = self::getWorkerInfo($system,$themeid,$page_index);        $where = ' where t.themeid ='. $themeid;        switch ($trace_type){            case 1:     //未付款                $where.= " and a.is_pay = 0 and a.sign_type>0";                break;            case 2:    //已付款                $where.= " and a.is_pay = 1 and a.sign_type>0";                break;            case 3:    //未追踪                $where.= " and a.is_pay = 0 and a.sign_type=0";                break;            case 4:    //已追踪 未标记                $where.= " and a.is_pay = 1 and a.sign_type=1";                break;            case 5:    //意向                $where.= " and a.is_pay = 1 and a.sign_type=2";                break;            case 6:   //潜在                $where.= " and a.is_pay = 1 and a.sign_type=3";                break;            case 7:  //无意向                $where.= " and a.is_pay = 1 and a.sign_type=4";                break;            case 8:  //待回访                $now_time = date('Y-m-d H:i:s',time());                $where .= " and a.is_pay=0 and a.trace_next_time>"."'".$now_time."'";                break;            default:                $where.= " and a.is_pay = 0 and a.sign_type>0";                break;        }        if($select_workerid){            $where .= ' and t.workerid ='. $select_workerid;        }else{            if($worker_id){                if(strpos($worker_id,',')){                    $where .= " and t.workerid in(". $worker_id.")";                }else{                    $where .= ' and t.workerid ='. $worker_id;                }            }        }        if($keyword){            $where .= " AND (f1.nickname LIKE '%".$keyword."%'"." or f1.mobile LIKE '".$keyword."' "." or f1.username LIKE '%".$keyword."%')";        }        $total_sql = "SELECT count(distinct t.uid) as cnt FROM " . tablename(t_userdata_trace)." as t".            " JOIN " . tablename(t_userdata_all) . " AS a on t.uid=a.uid and t.themeid = a.themeid and a.is_pay=0 ".            " LEFT JOIN " . tablename(t_fans) . " AS f1 on a.uid=f1.uid and a.themeid = f1.themeid ".$where;        $count = db_find($total_sql)['cnt'];        $page_size = 10;        $page_start = ($page_index-1)*$page_size;        $limit = " LIMIT " . $page_start . "," . $page_size;        $sql = "SELECT t.uid,t.themeid,group_concat(t.id order by t.id desc) as trace_ids,a.is_pay,a.sign_type,a.typesnum,a.trace_next_time,                ifnull(f1.avatar,'https://css2020.yixuan.net/2020css/yx2020/images/question.png') as user_avater,ifnull(f1.nickname,'') as user_nickname,ifnull(f1.username,'') as user_username,ifnull(f1.mobile,'') as user_mobile  FROM ".tablename(t_userdata_trace)." as t ".            " JOIN " . tablename(t_userdata_all) . " AS a on t.uid=a.uid and t.themeid = a.themeid".            " LEFT JOIN " . tablename(t_fans) . " AS f1 on a.uid=f1.uid and a.themeid = f1.themeid "            .$where.            " GROUP BY t.uid ORDER BY MAX(t.id) DESC". $limit;        $list = db_select($sql);        $max_page = ceil($count/$page_size);        if ($max_page>$page_index){            $can_next = true;        }        //查询追踪记录        foreach($list as $k => $val){            if($val['trace_next_time']=='0000-00-00 00:00:00'||!$val['trace_next_time']){                $list[$k]['trace_next_time'] = '';            }            $trace_ids = $val['trace_ids'];            $trace_sql = "SELECT * FROM ".tablename(t_userdata_trace)." WHERE id in(".$trace_ids.") AND uid =".$val['uid'] ." AND themeid=".$val['themeid']." ORDER BY id DESC";            $trace_list = db_select($trace_sql);            foreach ($trace_list as $k2 => $val2){                $worker = $worker_list[$val2['workerid']];                if($worker){                    $trace_list[$k2]['avatar'] = $val2['avatar']?$val2['avatar']:'https://css2020.yixuan.net/2020css/yx2020/images/question.png';                    $trace_list[$k2]['compnay_name'] = $worker['compnay_name'];                    $trace_list[$k2]['team_name'] =$worker['team_name'];                    $trace_list[$k2]['username'] =$worker['username'];                }            }            $list[$k]['sign_name'] = self::showSignType($val['sign_type']);            $list[$k]['typesnum'] =  self::typesNum($val['typesnum']);;            $list[$k]['trace_list'] = $trace_list;        }        $info = [            'hasNext'=>$can_next,            'curPageData'=>$list,            'page'=>$page_index,            'totalPage'=>$max_page,            'totalSize'=>$count,        ];        return $info;    }    /**     * Desc:我的日志列表     * User:wyx     * Time: 2022/4/28 10:47 上午     * @param $themeid     * @param $workerid     * @param $uid     * @param $type     * @return array     */    public static function  logdataMyList($system,$config,$themeid,$workerid,$uid,$type){        global $_G,$_P,$_S,$_C;        $page_index = max(1,intval($_P['page']));        $worker_list = self::getWorkerInfo($system,$themeid,$page_index);        $sign_type =    db_getcolumn(t_userdata_all, array('themeid' => $themeid ,'uid' => $uid),'sign_type');        $is_pay =    db_getcolumn(t_userdata_all, array('themeid' => $themeid ,'uid' => $uid),'is_pay');        $condition = ' where r.themeid ='. $themeid.' and r.uid = '.$uid;        if($type>0){            $condition .= ' and r.type ='. $type;        }        if($workerid){            if(strpos($workerid,',')){                $condition .= " and r.workerid in(". $workerid.")";            }else{                $condition .= ' and r.workerid ='. $workerid;            }        }        $total_sql = "SELECT count(*) as cnt FROM " . tablename(t_userdata_record).' as r '.$condition;        $count = db_find($total_sql)['cnt'];        $page_size = $_P['page_size']?$_P['page_size']:10;        $page_start = ($page_index-1)*$page_size;        $condition .= " ORDER BY r.id desc ";        $condition .= " LIMIT " . $page_start . "," . $page_size;        $sql = "SELECT r.*,ifnull(f2.avatar,'https://css2020.yixuan.net/2020css/yx2020/images/question.png') as fromuser_avater,ifnull(f2.nickname,'') as fromuser_nickname,ifnull(f2.username,'') as fromuser_username,ifnull(f2.mobile,'') as fromuser_mobile  FROM " . tablename(t_userdata_record) . " AS  r " .            " LEFT JOIN " . tablename(t_fans) . " AS f2 on r.from_uid=f2.uid and r.themeid = f2.themeid" .$condition;        $list = db_select($sql);        $fans = db_find("SELECT ifnull(avatar,'https://css2020.yixuan.net/2020css/yx2020/images/question.png') as user_avater,ifnull(nickname,'') as user_nickname,ifnull(username,'') as user_username,ifnull(mobile,'') as user_mobile                            FROM " . tablename(t_fans) ." WHERE uid={$uid} and themeid={$themeid}");        $pay_class ='payTag';        if ($config['yukuan'] > 0 && TIMESTAMP > $config['yukuantime']) {            $record_where = " AND uid = {$uid}";            $weibukuan_user_sql ="SELECT id,uid,themeid,status,type,addtime FROM ". tablename ( t_record )."  WHERE themeid ='{$themeid}' AND addtime<'{$config['yukuantime']}' AND status > 0  {$record_where}";            $weibukuan_user = db_find($weibukuan_user_sql);            $bukuan_user_sql = " SELECT id,uid,themeid,status,type,addtime FROM ".tablename(t_record)." WHERE themeid = {$themeid}  AND addtime>='{$config['yukuantime']}' {$record_where} ";            $yibukuan_user = db_find($bukuan_user_sql);            if($weibukuan_user&&$yibukuan_user){         //存在未补款数据和已补款数据                $pay_txt ='已补款';            }elseif($weibukuan_user){        //存在预付款订单                $pay_txt ='未补款';                $pay_class = 'unlabeledTag';            }elseif($yibukuan_user){         //存在尾款订单                $pay_txt ='全款';                $pay_class ='markTag';            }else{                $pay_txt ='未付';            }        }else{            $pay_txt = $is_pay == 1?'已付':'未付';        }        $max_page = ceil($count/$page_size);        if ($max_page>$page_index){            $can_next = true;        }        foreach($list as $k => $val){            $link_array = self::linkType($val['link_type']);            $list[$k]['user_avater'] = $fans['user_avater']?$fans['user_avater']:'https://css2020.yixuan.net/2020css/yx2020/images/question.png';            $list[$k]['user_nickname'] = $fans['user_nickname'];            $list[$k]['user_username'] = $fans['user_username'];            $list[$k]['user_mobile'] = $fans['user_mobile'];            $list[$k]['type_name'] = self::dataType($val['type'])['name'];            $list[$k]['link_name'] = $link_array['name'];            $list[$k]['link_color'] = $link_array['color'];            $list[$k]['is_pay'] =  $is_pay;            $list[$k]['sign_type'] =  $sign_type;            $list[$k]['sign_name'] = self::showSignType($sign_type);            $list[$k]['show_visit'] = self::visitType($val['type']);            $list[$k]['time_span'] = timeConversion($val['create_time']);            $list[$k]['is_work'] = 0;            $list[$k]['pay_txt'] = $pay_txt;            $list[$k]['pay_class'] = $pay_class;            $worker = array();            if($val['type']==1)            {                $worker = $worker_list[$val['workerid']];            }            if($worker){                if($val['workerid']==$val['from_uid']){                    $list[$k]['is_work'] = 1;                }                $list[$k]['worker'] = trim($worker['compnay_name'].' '.$worker['team_name'].' '.$worker['username']);            }else{                $list[$k]['worker'] = '';            }        }        $info = [            'hasNext'=>$can_next,            'curPageData'=>$list,            'page'=>$page_index,            'totalPage'=>$max_page,            'totalSize'=>$count,        ];        return $info;    }    /**     * Desc:用户日志记录     * User:wyx     * Time: 2022/4/28 11:11 上午     * @param $themeid     * @param $workerid     * @param $uid     * @return array     */    public static function  userTraceList($system,$themeid,$workerid,$uid){        global $_G,$_P,$_S,$_C;        $page_index = max(1,intval($_P['page']));        $worker_list = self::getWorkerInfo($system,$themeid,$page_index);        $condition = ' where themeid='. $themeid.' and uid='.$uid;        if($workerid){            if(strpos($workerid,',')){                $condition .= " and workerid in(". $workerid.")";            }else{                $condition .= ' and workerid ='. $workerid;            }        }        $total_sql = "SELECT count(*) as cnt FROM " . tablename(t_userdata_trace). $condition;        $count = db_find($total_sql)['cnt'];        $page_size = $_P['page_size']?$_P['page_size']:10;        $page_start = ($page_index-1)*$page_size;        $condition .= " ORDER BY id desc ";        $condition .= " LIMIT " . $page_start . "," . $page_size;        $user_all_sql = "select *  from ".tablename(t_userdata_trace). $condition;        $list = db_select($user_all_sql);        $max_page = ceil($count/$page_size);        if ($max_page>$page_index){            $can_next = true;        }        foreach($list as $k => $val){            $list[$k]['worker'] = $worker_list[$val['workerid']];            $list[$k]['sign_name'] = self::signType($val['sign_type']);        }        $info = [            'hasNext'=>$can_next,            'curPageData'=>$list,            'page'=>$page_index,            'totalPage'=>$max_page,            'totalSize'=>$count,        ];        return $info;    }    /**     * Desc:前端页面调用     * User:wyx     * Time: 2022/4/28 11:13 上午     * @param $config     * @return array     */    public static function AddlogPage($config){        global $_G, $_P;        $themeid = intval($_P['themeid']);        $type = intval($_P['type']);        if ( $type <10000 && $type !=10 && $type !=5 && $type !=1 ){            return array('error'=>1,'msg'=>'参数错误');        }        $uid = empty($_G['member']['uid'])?$_G['member']['uid']:$_G['member']['uid'];        if (empty($uid)){            return array('error'=>0,'msg'=>'无权访问：UID为空');        }        if ($type ==1 ){            $user_all_sql = "select * from ".tablename(t_userdata_record)." where `uid` = '{$uid}' and `type` = 1 order by id desc limit 1";            $user_all_data = db_find($user_all_sql);            if (!empty($user_all_data)){                $stay_time = time()-strtotime($user_all_data['create_time']);                if ($stay_time>1 && $stay_time<1000){                    db_update(t_userdata_record,array('standing_time'=>$stay_time),array('id'=>$user_all_data['id']));                }            }        }else{            $remark = trim($_P['remark']);            if ($config['groupprice2']>0 || $config['groupprice3']>0) {                $group_name = Record::getGroupName($config);            }            if ($type >20000 ) {                $op = $type - 20000;                $type = 5;                switch ($op) {                    case 1:                        $remark = '点击立即抢购';                        break;                    case 2:                        $remark = '点击加入团';                        break;                    case 3:                        $remark = '点击单独购买';                        break;                    case 4:                        $remark = '点击立即抢购（'.$group_name[1].'）';                        break;                    case 5:                        $remark = '点击立即抢购（'.$group_name[2].'）';                        break;                    case 8:                        $remark = '点击补余款';                        break;                    case 41:                        $remark = '预约拍摄';                        break;                    case 42:                        $remark = '查看预约';                        break;                    default:                        $type = 0;                        break;                }            }            elseif ($type >= 10000 ) {                //小程序点击事件处理                $op = $type - 10000;                $type = 5;                switch ($op) {                    case 1:                        $remark = '点击立即抢购';                        break;                    case 2:                        $remark = '点击加入团';                        break;                    case 3:                        $remark = '点击单独购买';                        break;                    case 4:                        $remark = '点击立即抢购（'.$group_name[1].'）';                        break;                    case 5:                        $remark = '点击立即抢购（'.$group_name[2].'）';                        break;                    case 13:                        $remark = '点击加入团';                        break;                    case 16:                        $remark = '返回我的链接'; //帮好友助力或点亮星星时                        break;                    case 41:                        $remark = '预约拍摄';                        break;                    case 42:                        $remark = '查看预约';                        break;                    //盲盒部分                    case 21:                        $remark = '点击开新团';                        break;                    case 22:                        $remark = '点击一键拼团';                        break;                    case 23:                        $remark = '查看拼团进度';                        break;                    case 24:                        $remark = '查看盲盒进度';                        break;                    case 25:                        $remark = '点击补全款';                        break;                    case 27:                        $remark = '返回首页';                        break;                    case 29:                        $remark = '查看我的盲盒';                        break;                    default:                        $type = 0;                        break;                }            }            if ($type!=0){                Userdata::addLog($themeid,$uid, $type,$remark);            }        }        return array('error'=>0,'data'=>array('msg'=>$uid . ":" . $type."-".$remark));    }    public static function getMobileCheck($themeid){        $sql = "select count(*) from " .tablename(t_userdata_record) . " where themeid = '" .$themeid."' and type = 36";        $count =  (int)db_fetchcolumn($sql);        if ($count>0){            $start_day =db_fetchcolumn ( 'SELECT min(addtime) FROM ' . tablename ( t_fans ) );            if ($start_day<1693152000){                $count = 0;            }        }        return $count*0.03;    }    /**     * Desc:     * User:wyx     * Time: 2022/4/28 11:21 上午     * @param $system     * @param $theme     * @param $config     * @param $fans     * @param $themeid     * @param $myworker     * @return array|void     */    public static function Main($system,$theme,$config,$fans,$themeid,$myworker){        global $_P,$_G;        $fromuid = intval($_P['fromuid']);        $op = !empty($_P['op'])?$_P['op']:'log_list';        if ($op != 'addlog'){            if (empty($myworker)){                return array('error'=>1,'msg'=>'您不是员工,无权访问');            }elseif (!($config['is_view_user_log']==0 || ($config['is_view_user_log']==1 && $myworker['level']==1))){                return array('error'=>1,'msg'=>'无权访问：查看权限未开启');            }        }        $level = $myworker['level'];        $workerid = intval($myworker['uid']);        $worker_id = Userdata::workerLevel($themeid,$workerid,$level);        $page_index = intval($_P['page']);        $uid = intval($_P['uid']);        $type = $_P['type'];        $keyword = $_P['keyword'];        $is_refresh = isset($_P['is_refresh'])?intval($_P['is_refresh']):0;        $result = array();        $result['uid'] = $uid;        $result['type'] = $type;        $result['op'] = $op;        $result['level'] = $level;        $result['keyword'] = $keyword;        $result['workerid'] = $workerid;        $result['main'] = 'userdata';        switch ($op){            case 'addlog':     //日志列表                return self::AddlogPage($config);            case 'log_list':     //日志列表                $select_workerid = $_P['select_workerid'];                $keyword = $_P['keyword'];                $result['res_list'] = Userdata::logdataList($system,$config,$themeid,$worker_id,$select_workerid,$workerid,$is_refresh,$keyword);                if($page_index <2){                    //$result['types_data'] = Userdata::allTypeNum($themeid,1);                    $worker_list = Userdata::getWorkerUidAndName($themeid,$worker_id);                    $result['select_workerid'] = $select_workerid;                    $result['worker_list'] = $worker_list;                    $result['page']='fcworker/fc_userdata_journal';                }                return array('error'=>0,'data'=>$result);            case 'focuse_list':   //关注列表                $type = $_P['type']?$_P['type']:1;                $type_num = $_P['type_num']?$_P['type_num']:10;                $result['res_list'] = Userdata::focuseList($system,$themeid,$worker_id,$type,$type_num);                if($page_index <2){                    $types_data = Userdata::allTypeNum($themeid,1);                    $quick_input = Userdata::focuseQuickSelect($themeid,$config,$worker_id);                    $result['type'] = $type;                    $result['type_num'] = $type_num;                    $result['types_data'] = $types_data;                    $result['quick_input'] = $quick_input;                    $result['page']='fcworker/fc_userdata_focuse';                }                return array('error'=>0,'data'=>$result);            case 'trace_list':     //追踪列表                $trace_type = $_P['trace_type'];                $keyword = $_P['keyword'];                $select_workerid = $_P['select_workerid'];                $result['res_list'] = Userdata::traceList($system,$themeid,$select_workerid,$worker_id,$trace_type,$keyword);                if($page_index < 2){                    $result['select_workerid'] = $select_workerid;                    $result['trace_type'] = $trace_type;                    $result['wait_trace_num'] = Userdata::waitTraceNum($themeid);                    $result['worker_list'] = Userdata::getWorkerUidAndName($themeid,$worker_id);                    $result['page']='fcworker/fc_userdata_fllow';                }                return array('error'=>0,'data'=>$result);            case 'user_log_list': // 用户日志列表                $result['res_list'] = Userdata::logdataMyList($system,$config,$themeid,$worker_id,$uid,$type);                if($page_index <2){                    $result['user_data'] = Userdata::getUserAllData($themeid,$uid);                    $result['page']='fcworker/fc_userdata_userjournal';                }                return array('error'=>0,'data'=>$result);            case 'user_trace_list':  //用户追踪列表                $result['res_list'] = Userdata::userTraceList($system,$themeid,$worker_id,$uid);                if($page_index <2){                    $result['quick_input']  = Userdata::workerQuickInput($config,$myworker['uid']);                    $result['user_data'] = Userdata::getUserAllData($themeid,$uid);                    $result['page']='fcworker/fc_userdata_userfllow';                }                return array('error'=>0,'data'=>$result);            case 'add_trace':    //提交追踪记录                $sign_type = $_P['sign_type'];                $content = $_P['content'];                $next_time = $_P['next_time'];                $res = Userdata::addTrace($themeid,$uid,$workerid,$sign_type,$content,$next_time);                return $res;            case 'submit_quickinput': //提交快捷输入                $content = $_P['content'];                $res = Userdata::submitQuickInput($themeid,$workerid,$content);                return $res;        }    }}